package com.lmscn.lms.api.model;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/**
 * Created by Czl on 2015/7/25.
 */
@SuppressWarnings("serial")
public class CourseStudentProgress extends Model<CourseStudentProgress> {

    public static final CourseStudentProgress dao = new CourseStudentProgress();

    /**
     * 保存学习进度
     * @param csp
     * @param courseStudentId
     * @param courseId
     * @param studentId
     */
    public void saveCourseStudentProgress(CourseStudentProgress csp,Long courseStudentId,Long courseId,Long studentId){
        csp.set("course_student_id",courseStudentId);
        csp.set("course_id",courseId);
        csp.set("student_id",studentId);
        csp.remove("id").save();
    }

    /**
     * 删除选课进度信息
     * @param courseStudentId
     * @param courseId
     * @param studentId
     */
    public void deleteCourseStudentProgress(Long courseStudentId,Long courseId,Long studentId){
        Db.update("delete from t_course_student_progress " +
                "where course_student_id = ? and course_id =? and student_id = ?",courseStudentId,courseId,studentId);
    }
}
